package com.heima.admin.job;

import com.heima.admin.service.WemediaNewsAutoScanService;
import com.heima.feigns.wemedia.WemediaFeign;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Jt
 * @date 2021/4/20 17:19
 */
@Component
@Slf4j
public class WeMediaNewsAutoScanJob {

    @Resource
    private WemediaNewsAutoScanService wemediaNewsAutoScanService;

    @Resource
    private WemediaFeign wemediaFeign;

    @XxlJob("wemediaAutoScanJob")
    public ReturnT<String> autoScanJob (String param) throws Exception{
        log.info("自媒体文章审核调度任务开始执行...");
        List<Integer> release = wemediaFeign.findRelease();
        if (release != null && !release.isEmpty()) {
            for (Integer id : release) {
                wemediaNewsAutoScanService.autoScanByMediaNewsId(id);
            }
        }
        log.info("自媒体文章审核调度任务执行结束...");
        return ReturnT.SUCCESS;
    }

}
